import { createRouter, createWebHashHistory } from 'vue-router'

// 导入路由模块
import Layout from '@/views/Layout'
import Login from '@/views/Login'
import Category from '@/views/Category'
import Home from '@/views/Home'
import Good from '@/views/Good'
// 创建路由实例
const routes = [
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/',
    name: 'Layout',
    component: Layout,
    children: [
      {
        path: '',
        component: Home
      },
      {
        path: 'category/:id',
        component: Category,
        name: 'category'
      },
      {
        path: 'good/:id',
        component: Good,
        name: 'Good'
      }

    ]
  }
]

const router = createRouter({
  // 使用hash方式实现路由
  history: createWebHashHistory(),
  // 配置路由规则，写法和之前一样
  routes
})

export default router
